
# ifndef __DFX_OGG_PROVIDER_H__
# define __DFX_OGG_PROVIDER_H__

# include "dfxWaveDataProvider.h"
# include "dfxStream.h"
# include "dfxMemoryFile.h"

# include "libvorbis/vorbis/codec.h"
# include "libvorbis/vorbis/vorbisfile.h"
# include "libvorbis/ogg/os_types.h"

namespace DFX
{
    class DFX_EXPORT OggProvider : public DecodingProvider
    {
    private:

        OggVorbis_File  mVorbisFile;
        ogg_int64_t     mOGRawPosition;
        Int32           mCurrentSection;
        MemoryFile      *mOggFile;
        InputStream     *mStream;

    public:

        OggProvider();
        ~OggProvider();

        DFXRESULT Load(FileBase *file);
        DFXRESULT Destroy();

        Int32 ReadFromFile(UInt32 size, UInt32 bytesRead);
        void Seek(Float32 time);

    private:

        static size_t OGG_ReadFunc(void *ptr, size_t size, size_t nMemB, void *dataSource);
        static int OGG_SeekFunc(void *dataSource, ogg_int64_t offset, int whence);
        
        static int OGG_CloseFunc(void *dataSource);
        static long OGG_TellFunc(void *dataSource);
    };
}

# endif